home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / BCCGRX12.ZIP / contrib / bcc2grx / src / bccgrx05.c < prev    next >
C/C++ Source or Header  |  1993-05-04  |  2KB  |  75 lines

  1. /*
  2.  *  BCC2GRX  -  Interfacing Borland based graphics programs to LIBGRX
  3.  *  Copyright (C) 1993  Hartmut Schirmer
  4.  *
  5.  *  see bccgrx.c for details
  6.  */
  7.  
  8. #include "bccgrx00.h"
  9.  
  10. static unsigned short usr_pat = 0x0000;
  11.  
  12. #define user_len 32
  13. static unsigned char user[user_len];
  14.  
  15. void getlinesettings(struct linesettingstype  *lineinfo)
  16. {
  17.   _DO_INIT_CHECK;
  18.   lineinfo->linestyle = __gr_lstyle;
  19.   lineinfo->upattern  = usr_pat;
  20.   lineinfo->thickness = LNE.lno_width;
  21. }
  22.  
  23. /* ----------------------------------------------------------------- */
  24. void setlinestyle(int linestyle, unsigned upattern, int thickness)
  25. {
  26.   int i, j;
  27.  
  28.   _DO_INIT_CHECK;
  29.   switch (linestyle) {
  30.     case SOLID_LINE  : LNE.lno_pattlen = 0;
  31.                LNE.lno_dashpat = NULL;
  32.                break;
  33.     case DOTTED_LINE : LNE.lno_pattlen = 3;
  34.                LNE.lno_dashpat = "\0\2\2";
  35.                break;
  36.     case CENTER_LINE : LNE.lno_pattlen = 5;
  37.                LNE.lno_dashpat = "\0\3\4\3\6";
  38.                break;
  39.     case DASHED_LINE : LNE.lno_pattlen = 5;
  40.                LNE.lno_dashpat = "\0\3\5\3\5";
  41.                break;
  42.     case USERBIT_LINE: usr_pat = upattern;
  43.                if (upattern == 0xFFFF) {
  44.              LNE.lno_pattlen = 0;
  45.              LNE.lno_dashpat = NULL;
  46.              break;
  47.                }
  48.                j = 0;
  49.                user[0] = 0;
  50.                for (i=0; i < 16; ++i) {
  51.              if ( (upattern & 1) == 0) {
  52.                if ( (j&1) == 0) {
  53.                  ++j;
  54.                  user[j] = 0;
  55.                }
  56.                ++user[j];
  57.              } else {
  58.                if ( (j&1) != 0) {
  59.                  ++j;
  60.                  user[j] = 0;
  61.                }
  62.                ++user[j];
  63.              }
  64.              upattern >>= 1;
  65.                }
  66.                LNE.lno_pattlen = j+1;
  67.                LNE.lno_dashpat = user;
  68.                break;
  69.     default          : ERR = grError;
  70.                return;
  71.   }
  72.   __gr_lstyle     = linestyle;
  73.   LNE.lno_width   = thickness;
  74. }
  75.